package com.mes.cloud.web;

import com.mes.cloud.api.dto.request.SubordinateRequest;
import com.mes.cloud.api.dto.request.position.BatchDeletePositionSuperiorRequest;
import com.mes.cloud.api.dto.request.position.BindPositionSuperiorRequest;
import com.mes.cloud.api.dto.request.position.SysPositionSuperiorPageRequest;
import com.mes.cloud.api.dto.request.position.SysPositionSuperiorRequest;
import com.mes.cloud.api.dto.response.position.SysPositionSuperiorDto;
import com.mes.cloud.common.CommPager;
import com.mes.cloud.common.JsonResult;
import com.mes.cloud.service.SysPositionSuperiorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author 郑样平
 * @version 2019-08-26 14:29:01
 * @email xiaomin.wu1@pactera.com
 */
@Api(tags = "岗位上级岗位关联表", value = "岗位上级岗位关联表接口")
@RestController
@RequestMapping(value = "/sysPositionSuperior")
public class SysPositionSuperiorController {

    private SysPositionSuperiorService sysPositionSuperiorService;

    @Autowired
    public SysPositionSuperiorController(SysPositionSuperiorService sysPositionSuperiorService) {
        this.sysPositionSuperiorService = sysPositionSuperiorService;
    }

    @ApiOperation(value = "上级岗位列表", notes = "上级岗位列表")
    @PostMapping(value = "/positionSuperiorList")
    public JsonResult<CommPager<SysPositionSuperiorDto>> positionSuperiorList(@Valid @RequestBody SysPositionSuperiorPageRequest sysPositionSuperiorPageRequest) {
        return sysPositionSuperiorService.positionSuperiorList(sysPositionSuperiorPageRequest);
    }

    @ApiOperation(value = "岗位添加上级岗位", notes = "员工添加岗位")
    @PostMapping(value = "/bindPositionSuperior")
    public JsonResult bindPositionSuperior(@Valid @RequestBody BindPositionSuperiorRequest bindPositionSuperiorRequest) {
        return sysPositionSuperiorService.bindPositionSuperior(bindPositionSuperiorRequest);
    }

    @ApiOperation(value = "岗位移除上级岗位", notes = "岗位移除上级岗位")
    @PostMapping(value = "/batchDeletePositionSuperior")
    public JsonResult batchDeletePositionSuperior(@Valid @RequestBody BatchDeletePositionSuperiorRequest batchDeleteRequest) {
        return sysPositionSuperiorService.batchDeletePositionSuperior(batchDeleteRequest);
    }

    @ApiOperation(value = "查询岗位上级信息", notes = "查询岗位上级信息")
    @PostMapping(value = "/getSysPositionSuperior")
    public JsonResult<SysPositionSuperiorDto> getSysPositionSuperior(@Valid @RequestBody SysPositionSuperiorRequest request) {
        return sysPositionSuperiorService.getSysPositionSuperior(request);
    }

    @ApiOperation(value = "是否包含下级岗位（0-否，1-是）", notes = "是否包含下级岗位（0-否，1-是）")
    @PostMapping(value = "/getSubordinate")
    public JsonResult<String> getSubordinate(@Valid @RequestBody SubordinateRequest subordinateRequest) {
        return sysPositionSuperiorService.getSubordinate(subordinateRequest);
    }
}
